<?php
class NavMenu {
	
	var $target         = NULL;
	var $output         = NULL;
	 
	var $full_tag_open  = '<ul>';
	var $full_tag_close = '</ul>';
	var $item_tag_open  = '<li>';
	var $item_tag_close = '</li>';
	var $cur_page       = '';
	var $cur_class      = 'selected';
	var $cur_display    = TRUE;
	
	
	function NavMenu() {
		
	}

	
	
	
	private function _data() {
		$menu_data = array(
            'header' => array(
							array('name'  => 'Home',
                                  'slug'  => '',
                                  'class' => 'homepage'),
	 
							array('name'  => 'My Jobs',
                                  'slug'  => 'work',
                                  'class' => ''),
		 
							array('name'  => 'Talk to Me',
                                  'slug'  => 'contact',
                                  'class' => '')
		),
		 
	            'footer' => array(
							array('name'  => 'About Us',
                                  'slug'  => 'about',
                                  'class' => '')
		)
		 
		);
		 
		if ( ! empty($menu_data))
		{
			if (array_key_exists($this->target, $menu_data))
			{
				return $menu_data[$this->target];
			}
		}
	}
	
	
	
	private function _create_links() {
		$CI =& get_instance();
		 
		$this->cur_page = trim_slashes($CI->uri->ruri_string());
		$li = NULL;
		 
		foreach($this->_data() as $line)
		{
			if($this->cur_display == TRUE)
			{
				($this->cur_page == $line['slug']) ? $line['class'] = $line['class'].' '.$this->cur_class : $line['class'];
			}
			 
			$li .= $this->item_tag_open.anchor($line['slug'], $line['name'], array('class' => $line['class'])).$this->item_tag_close;
		}
		 
		$this->output = $this->full_tag_open.$li.$this->full_tag_close;
		 
		return $this->output;
	}
	
	
	 
	public function render($input) {
		$this->target = $input;
		 
		if ($this->target != NULL)
		{
			return $this->_create_links();
		}
	}
	
	
	public function test() {
		
		return 'test';
		
	}
	
	
	
	
}